/*
 *
 * Copyright (c) 2013-2021, Alibaba Group Holding Limited;
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: TxnStream.proto

package com.aliyun.polardbx.binlog.protocol;

/**
 * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnToken}
 */
public final class TxnToken extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:com.aliyun.polardbx.binlog.protocol.TxnToken)
    TxnTokenOrBuilder {
    private static final long serialVersionUID = 0L;

    // Use TxnToken.newBuilder() to construct.
    private TxnToken(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
        super(builder);
    }

    private TxnToken() {
        tso_ = "";
        txnId_ = "";
        partitionId_ = "";
        originMergeSourceId_ = "";
        type_ = 0;
        beginSchema_ = "";
        allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY;
        payload_ = com.google.protobuf.ByteString.EMPTY;
    }

    @java.lang.Override
    @SuppressWarnings({"unused"})
    protected java.lang.Object newInstance(
        UnusedPrivateParameter unused) {
        return new TxnToken();
    }

    @java.lang.Override
    public final com.google.protobuf.UnknownFieldSet
    getUnknownFields() {
        return this.unknownFields;
    }

    private TxnToken(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        this();
        if (extensionRegistry == null) {
            throw new java.lang.NullPointerException();
        }
        int mutable_bitField0_ = 0;
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
            com.google.protobuf.UnknownFieldSet.newBuilder();
        try {
            boolean done = false;
            while (!done) {
                int tag = input.readTag();
                switch (tag) {
                case 0:
                    done = true;
                    break;
                case 10: {
                    java.lang.String s = input.readStringRequireUtf8();

                    tso_ = s;
                    break;
                }
                case 18: {
                    java.lang.String s = input.readStringRequireUtf8();

                    txnId_ = s;
                    break;
                }
                case 26: {
                    java.lang.String s = input.readStringRequireUtf8();

                    partitionId_ = s;
                    break;
                }
                case 34: {
                    java.lang.String s = input.readStringRequireUtf8();

                    originMergeSourceId_ = s;
                    break;
                }
                case 40: {
                    int rawValue = input.readEnum();

                    type_ = rawValue;
                    break;
                }
                case 48: {

                    xaTxn_ = input.readBool();
                    break;
                }
                case 56: {

                    tsoTransaction_ = input.readBool();
                    break;
                }
                case 64: {

                    txnSize_ = input.readInt32();
                    break;
                }
                case 74: {
                    java.lang.String s = input.readStringRequireUtf8();

                    beginSchema_ = s;
                    break;
                }
                case 82: {
                    java.lang.String s = input.readStringRequireUtf8();
                    if (!((mutable_bitField0_ & 0x00000001) != 0)) {
                        allParties_ = new com.google.protobuf.LazyStringArrayList();
                        mutable_bitField0_ |= 0x00000001;
                    }
                    allParties_.add(s);
                    break;
                }
                case 90: {

                    payload_ = input.readBytes();
                    break;
                }
                case 96: {

                    snapshotSeq_ = input.readInt64();
                    break;
                }
                default: {
                    if (!parseUnknownField(
                        input, unknownFields, extensionRegistry, tag)) {
                        done = true;
                    }
                    break;
                }
                }
            }
        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(this);
        } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(
                e).setUnfinishedMessage(this);
        } finally {
            if (((mutable_bitField0_ & 0x00000001) != 0)) {
                allParties_ = allParties_.getUnmodifiableView();
            }
            this.unknownFields = unknownFields.build();
            makeExtensionsImmutable();
        }
    }

    public static final com.google.protobuf.Descriptors.Descriptor
    getDescriptor() {
        return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
    internalGetFieldAccessorTable() {
        return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable
            .ensureFieldAccessorsInitialized(
                com.aliyun.polardbx.binlog.protocol.TxnToken.class,
                com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class);
    }

    public static final int TSO_FIELD_NUMBER = 1;
    private volatile java.lang.Object tso_;

    /**
     * <code>string tso = 1;</code>
     *
     * @return The tso.
     */
    @java.lang.Override
    public java.lang.String getTso() {
        java.lang.Object ref = tso_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            com.google.protobuf.ByteString bs =
                (com.google.protobuf.ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            tso_ = s;
            return s;
        }
    }

    /**
     * <code>string tso = 1;</code>
     *
     * @return The bytes for tso.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString
    getTsoBytes() {
        java.lang.Object ref = tso_;
        if (ref instanceof java.lang.String) {
            com.google.protobuf.ByteString b =
                com.google.protobuf.ByteString.copyFromUtf8(
                    (java.lang.String) ref);
            tso_ = b;
            return b;
        } else {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    public static final int TXNID_FIELD_NUMBER = 2;
    private volatile java.lang.Object txnId_;

    /**
     * <code>string txnId = 2;</code>
     *
     * @return The txnId.
     */
    @java.lang.Override
    public java.lang.String getTxnId() {
        java.lang.Object ref = txnId_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            com.google.protobuf.ByteString bs =
                (com.google.protobuf.ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            txnId_ = s;
            return s;
        }
    }

    /**
     * <code>string txnId = 2;</code>
     *
     * @return The bytes for txnId.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString
    getTxnIdBytes() {
        java.lang.Object ref = txnId_;
        if (ref instanceof java.lang.String) {
            com.google.protobuf.ByteString b =
                com.google.protobuf.ByteString.copyFromUtf8(
                    (java.lang.String) ref);
            txnId_ = b;
            return b;
        } else {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    public static final int PARTITIONID_FIELD_NUMBER = 3;
    private volatile java.lang.Object partitionId_;

    /**
     * <code>string partitionId = 3;</code>
     *
     * @return The partitionId.
     */
    @java.lang.Override
    public java.lang.String getPartitionId() {
        java.lang.Object ref = partitionId_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            com.google.protobuf.ByteString bs =
                (com.google.protobuf.ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            partitionId_ = s;
            return s;
        }
    }

    /**
     * <code>string partitionId = 3;</code>
     *
     * @return The bytes for partitionId.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString
    getPartitionIdBytes() {
        java.lang.Object ref = partitionId_;
        if (ref instanceof java.lang.String) {
            com.google.protobuf.ByteString b =
                com.google.protobuf.ByteString.copyFromUtf8(
                    (java.lang.String) ref);
            partitionId_ = b;
            return b;
        } else {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    public static final int ORIGINMERGESOURCEID_FIELD_NUMBER = 4;
    private volatile java.lang.Object originMergeSourceId_;

    /**
     * <code>string originMergeSourceId = 4;</code>
     *
     * @return The originMergeSourceId.
     */
    @java.lang.Override
    public java.lang.String getOriginMergeSourceId() {
        java.lang.Object ref = originMergeSourceId_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            com.google.protobuf.ByteString bs =
                (com.google.protobuf.ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            originMergeSourceId_ = s;
            return s;
        }
    }

    /**
     * <code>string originMergeSourceId = 4;</code>
     *
     * @return The bytes for originMergeSourceId.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString
    getOriginMergeSourceIdBytes() {
        java.lang.Object ref = originMergeSourceId_;
        if (ref instanceof java.lang.String) {
            com.google.protobuf.ByteString b =
                com.google.protobuf.ByteString.copyFromUtf8(
                    (java.lang.String) ref);
            originMergeSourceId_ = b;
            return b;
        } else {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    public static final int TYPE_FIELD_NUMBER = 5;
    private int type_;

    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
     *
     * @return The enum numeric value on the wire for type.
     */
    @java.lang.Override
    public int getTypeValue() {
        return type_;
    }

    /**
     * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
     *
     * @return The type.
     */
    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.TxnType getType() {
        @SuppressWarnings("deprecation")
        com.aliyun.polardbx.binlog.protocol.TxnType result = com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_);
        return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result;
    }

    public static final int XATXN_FIELD_NUMBER = 6;
    private boolean xaTxn_;

    /**
     * <code>bool xaTxn = 6;</code>
     *
     * @return The xaTxn.
     */
    @java.lang.Override
    public boolean getXaTxn() {
        return xaTxn_;
    }

    public static final int TSOTRANSACTION_FIELD_NUMBER = 7;
    private boolean tsoTransaction_;

    /**
     * <pre>
     * *
     * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段，
     * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
     * </pre>
     *
     * <code>bool tsoTransaction = 7;</code>
     *
     * @return The tsoTransaction.
     */
    @java.lang.Override
    public boolean getTsoTransaction() {
        return tsoTransaction_;
    }

    public static final int TXNSIZE_FIELD_NUMBER = 8;
    private int txnSize_;

    /**
     * <pre>
     * *
     * 该事务下的所有LogEvent的个数，注意：不是某个批次的的个数
     * </pre>
     *
     * <code>int32 txnSize = 8;</code>
     *
     * @return The txnSize.
     */
    @java.lang.Override
    public int getTxnSize() {
        return txnSize_;
    }

    public static final int BEGINSCHEMA_FIELD_NUMBER = 9;
    private volatile java.lang.Object beginSchema_;

    /**
     * <pre>
     * *
     * dumper生成事务的begin头时使用
     * </pre>
     *
     * <code>string beginSchema = 9;</code>
     *
     * @return The beginSchema.
     */
    @java.lang.Override
    public java.lang.String getBeginSchema() {
        java.lang.Object ref = beginSchema_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            com.google.protobuf.ByteString bs =
                (com.google.protobuf.ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            beginSchema_ = s;
            return s;
        }
    }

    /**
     * <pre>
     * *
     * dumper生成事务的begin头时使用
     * </pre>
     *
     * <code>string beginSchema = 9;</code>
     *
     * @return The bytes for beginSchema.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString
    getBeginSchemaBytes() {
        java.lang.Object ref = beginSchema_;
        if (ref instanceof java.lang.String) {
            com.google.protobuf.ByteString b =
                com.google.protobuf.ByteString.copyFromUtf8(
                    (java.lang.String) ref);
            beginSchema_ = b;
            return b;
        } else {
            return (com.google.protobuf.ByteString) ref;
        }
    }

    public static final int ALLPARTIES_FIELD_NUMBER = 10;
    private com.google.protobuf.LazyStringList allParties_;

    /**
     * <code>repeated string allParties = 10;</code>
     *
     * @return A list containing the allParties.
     */
    public com.google.protobuf.ProtocolStringList
    getAllPartiesList() {
        return allParties_;
    }

    /**
     * <code>repeated string allParties = 10;</code>
     *
     * @return The count of allParties.
     */
    public int getAllPartiesCount() {
        return allParties_.size();
    }

    /**
     * <code>repeated string allParties = 10;</code>
     *
     * @param index The index of the element to return.
     * @return The allParties at the given index.
     */
    public java.lang.String getAllParties(int index) {
        return allParties_.get(index);
    }

    /**
     * <code>repeated string allParties = 10;</code>
     *
     * @param index The index of the value to return.
     * @return The bytes of the allParties at the given index.
     */
    public com.google.protobuf.ByteString
    getAllPartiesBytes(int index) {
        return allParties_.getByteString(index);
    }

    public static final int PAYLOAD_FIELD_NUMBER = 11;
    private com.google.protobuf.ByteString payload_;

    /**
     * <pre>
     * *
     * 一些特殊的TxnToken，没有TxnItem的概念，此时通过payload字段传输数据
     * </pre>
     *
     * <code>bytes payload = 11;</code>
     *
     * @return The payload.
     */
    @java.lang.Override
    public com.google.protobuf.ByteString getPayload() {
        return payload_;
    }

    public static final int SNAPSHOTSEQ_FIELD_NUMBER = 12;
    private long snapshotSeq_;

    /**
     * <pre>
     * *
     * Tso事务专用
     * </pre>
     *
     * <code>int64 snapshotSeq = 12;</code>
     *
     * @return The snapshotSeq.
     */
    @java.lang.Override
    public long getSnapshotSeq() {
        return snapshotSeq_;
    }

    private byte memoizedIsInitialized = -1;

    @java.lang.Override
    public final boolean isInitialized() {
        byte isInitialized = memoizedIsInitialized;
        if (isInitialized == 1) {
            return true;
        }
        if (isInitialized == 0) {
            return false;
        }

        memoizedIsInitialized = 1;
        return true;
    }

    @java.lang.Override
    public void writeTo(com.google.protobuf.CodedOutputStream output)
        throws java.io.IOException {
        if (!getTsoBytes().isEmpty()) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tso_);
        }
        if (!getTxnIdBytes().isEmpty()) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 2, txnId_);
        }
        if (!getPartitionIdBytes().isEmpty()) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 3, partitionId_);
        }
        if (!getOriginMergeSourceIdBytes().isEmpty()) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 4, originMergeSourceId_);
        }
        if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) {
            output.writeEnum(5, type_);
        }
        if (xaTxn_ != false) {
            output.writeBool(6, xaTxn_);
        }
        if (tsoTransaction_ != false) {
            output.writeBool(7, tsoTransaction_);
        }
        if (txnSize_ != 0) {
            output.writeInt32(8, txnSize_);
        }
        if (!getBeginSchemaBytes().isEmpty()) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 9, beginSchema_);
        }
        for (int i = 0; i < allParties_.size(); i++) {
            com.google.protobuf.GeneratedMessageV3.writeString(output, 10, allParties_.getRaw(i));
        }
        if (!payload_.isEmpty()) {
            output.writeBytes(11, payload_);
        }
        if (snapshotSeq_ != 0L) {
            output.writeInt64(12, snapshotSeq_);
        }
        unknownFields.writeTo(output);
    }

    @java.lang.Override
    public int getSerializedSize() {
        int size = memoizedSize;
        if (size != -1) {
            return size;
        }

        size = 0;
        if (!getTsoBytes().isEmpty()) {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tso_);
        }
        if (!getTxnIdBytes().isEmpty()) {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, txnId_);
        }
        if (!getPartitionIdBytes().isEmpty()) {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, partitionId_);
        }
        if (!getOriginMergeSourceIdBytes().isEmpty()) {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, originMergeSourceId_);
        }
        if (type_ != com.aliyun.polardbx.binlog.protocol.TxnType.DML.getNumber()) {
            size += com.google.protobuf.CodedOutputStream
                .computeEnumSize(5, type_);
        }
        if (xaTxn_ != false) {
            size += com.google.protobuf.CodedOutputStream
                .computeBoolSize(6, xaTxn_);
        }
        if (tsoTransaction_ != false) {
            size += com.google.protobuf.CodedOutputStream
                .computeBoolSize(7, tsoTransaction_);
        }
        if (txnSize_ != 0) {
            size += com.google.protobuf.CodedOutputStream
                .computeInt32Size(8, txnSize_);
        }
        if (!getBeginSchemaBytes().isEmpty()) {
            size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, beginSchema_);
        }
        {
            int dataSize = 0;
            for (int i = 0; i < allParties_.size(); i++) {
                dataSize += computeStringSizeNoTag(allParties_.getRaw(i));
            }
            size += dataSize;
            size += 1 * getAllPartiesList().size();
        }
        if (!payload_.isEmpty()) {
            size += com.google.protobuf.CodedOutputStream
                .computeBytesSize(11, payload_);
        }
        if (snapshotSeq_ != 0L) {
            size += com.google.protobuf.CodedOutputStream
                .computeInt64Size(12, snapshotSeq_);
        }
        size += unknownFields.getSerializedSize();
        memoizedSize = size;
        return size;
    }

    @java.lang.Override
    public boolean equals(final java.lang.Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof com.aliyun.polardbx.binlog.protocol.TxnToken)) {
            return super.equals(obj);
        }
        com.aliyun.polardbx.binlog.protocol.TxnToken other = (com.aliyun.polardbx.binlog.protocol.TxnToken) obj;

        if (!getTso()
            .equals(other.getTso())) {
            return false;
        }
        if (!getTxnId()
            .equals(other.getTxnId())) {
            return false;
        }
        if (!getPartitionId()
            .equals(other.getPartitionId())) {
            return false;
        }
        if (!getOriginMergeSourceId()
            .equals(other.getOriginMergeSourceId())) {
            return false;
        }
        if (type_ != other.type_) {
            return false;
        }
        if (getXaTxn()
            != other.getXaTxn()) {
            return false;
        }
        if (getTsoTransaction()
            != other.getTsoTransaction()) {
            return false;
        }
        if (getTxnSize()
            != other.getTxnSize()) {
            return false;
        }
        if (!getBeginSchema()
            .equals(other.getBeginSchema())) {
            return false;
        }
        if (!getAllPartiesList()
            .equals(other.getAllPartiesList())) {
            return false;
        }
        if (!getPayload()
            .equals(other.getPayload())) {
            return false;
        }
        if (getSnapshotSeq()
            != other.getSnapshotSeq()) {
            return false;
        }
        if (!unknownFields.equals(other.unknownFields)) {
            return false;
        }
        return true;
    }

    @java.lang.Override
    public int hashCode() {
        if (memoizedHashCode != 0) {
            return memoizedHashCode;
        }
        int hash = 41;
        hash = (19 * hash) + getDescriptor().hashCode();
        hash = (37 * hash) + TSO_FIELD_NUMBER;
        hash = (53 * hash) + getTso().hashCode();
        hash = (37 * hash) + TXNID_FIELD_NUMBER;
        hash = (53 * hash) + getTxnId().hashCode();
        hash = (37 * hash) + PARTITIONID_FIELD_NUMBER;
        hash = (53 * hash) + getPartitionId().hashCode();
        hash = (37 * hash) + ORIGINMERGESOURCEID_FIELD_NUMBER;
        hash = (53 * hash) + getOriginMergeSourceId().hashCode();
        hash = (37 * hash) + TYPE_FIELD_NUMBER;
        hash = (53 * hash) + type_;
        hash = (37 * hash) + XATXN_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
            getXaTxn());
        hash = (37 * hash) + TSOTRANSACTION_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
            getTsoTransaction());
        hash = (37 * hash) + TXNSIZE_FIELD_NUMBER;
        hash = (53 * hash) + getTxnSize();
        hash = (37 * hash) + BEGINSCHEMA_FIELD_NUMBER;
        hash = (53 * hash) + getBeginSchema().hashCode();
        if (getAllPartiesCount() > 0) {
            hash = (37 * hash) + ALLPARTIES_FIELD_NUMBER;
            hash = (53 * hash) + getAllPartiesList().hashCode();
        }
        hash = (37 * hash) + PAYLOAD_FIELD_NUMBER;
        hash = (53 * hash) + getPayload().hashCode();
        hash = (37 * hash) + SNAPSHOTSEQ_FIELD_NUMBER;
        hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
            getSnapshotSeq());
        hash = (29 * hash) + unknownFields.hashCode();
        memoizedHashCode = hash;
        return hash;
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        java.nio.ByteBuffer data)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        java.nio.ByteBuffer data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        com.google.protobuf.ByteString data)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        com.google.protobuf.ByteString data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(byte[] data)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        byte[] data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(java.io.InputStream input)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseWithIOException(PARSER, input);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseWithIOException(PARSER, input, extensionRegistry);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom(java.io.InputStream input)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseDelimitedWithIOException(PARSER, input);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseDelimitedFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        com.google.protobuf.CodedInputStream input)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseWithIOException(PARSER, input);
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken parseFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
        return com.google.protobuf.GeneratedMessageV3
            .parseWithIOException(PARSER, input, extensionRegistry);
    }

    @java.lang.Override
    public Builder newBuilderForType() {
        return newBuilder();
    }

    public static Builder newBuilder() {
        return DEFAULT_INSTANCE.toBuilder();
    }

    public static Builder newBuilder(com.aliyun.polardbx.binlog.protocol.TxnToken prototype) {
        return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }

    @java.lang.Override
    public Builder toBuilder() {
        return this == DEFAULT_INSTANCE
            ? new Builder() : new Builder().mergeFrom(this);
    }

    @java.lang.Override
    protected Builder newBuilderForType(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
        Builder builder = new Builder(parent);
        return builder;
    }

    /**
     * Protobuf type {@code com.aliyun.polardbx.binlog.protocol.TxnToken}
     */
    public static final class Builder extends
        com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
        // @@protoc_insertion_point(builder_implements:com.aliyun.polardbx.binlog.protocol.TxnToken)
        com.aliyun.polardbx.binlog.protocol.TxnTokenOrBuilder {
        public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
            return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor;
        }

        @java.lang.Override
        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
            return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_fieldAccessorTable
                .ensureFieldAccessorsInitialized(
                    com.aliyun.polardbx.binlog.protocol.TxnToken.class,
                    com.aliyun.polardbx.binlog.protocol.TxnToken.Builder.class);
        }

        // Construct using com.aliyun.polardbx.binlog.protocol.TxnToken.newBuilder()
        private Builder() {
            maybeForceBuilderInitialization();
        }

        private Builder(
            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
            super(parent);
            maybeForceBuilderInitialization();
        }

        private void maybeForceBuilderInitialization() {
            if (com.google.protobuf.GeneratedMessageV3
                .alwaysUseFieldBuilders) {
            }
        }

        @java.lang.Override
        public Builder clear() {
            super.clear();
            tso_ = "";

            txnId_ = "";

            partitionId_ = "";

            originMergeSourceId_ = "";

            type_ = 0;

            xaTxn_ = false;

            tsoTransaction_ = false;

            txnSize_ = 0;

            beginSchema_ = "";

            allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY;
            bitField0_ = (bitField0_ & ~0x00000001);
            payload_ = com.google.protobuf.ByteString.EMPTY;

            snapshotSeq_ = 0L;

            return this;
        }

        @java.lang.Override
        public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
            return com.aliyun.polardbx.binlog.protocol.TxnStream.internal_static_com_aliyun_polardbx_binlog_protocol_TxnToken_descriptor;
        }

        @java.lang.Override
        public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() {
            return com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance();
        }

        @java.lang.Override
        public com.aliyun.polardbx.binlog.protocol.TxnToken build() {
            com.aliyun.polardbx.binlog.protocol.TxnToken result = buildPartial();
            if (!result.isInitialized()) {
                throw newUninitializedMessageException(result);
            }
            return result;
        }

        @java.lang.Override
        public com.aliyun.polardbx.binlog.protocol.TxnToken buildPartial() {
            com.aliyun.polardbx.binlog.protocol.TxnToken result =
                new com.aliyun.polardbx.binlog.protocol.TxnToken(this);
            int from_bitField0_ = bitField0_;
            result.tso_ = tso_;
            result.txnId_ = txnId_;
            result.partitionId_ = partitionId_;
            result.originMergeSourceId_ = originMergeSourceId_;
            result.type_ = type_;
            result.xaTxn_ = xaTxn_;
            result.tsoTransaction_ = tsoTransaction_;
            result.txnSize_ = txnSize_;
            result.beginSchema_ = beginSchema_;
            if (((bitField0_ & 0x00000001) != 0)) {
                allParties_ = allParties_.getUnmodifiableView();
                bitField0_ = (bitField0_ & ~0x00000001);
            }
            result.allParties_ = allParties_;
            result.payload_ = payload_;
            result.snapshotSeq_ = snapshotSeq_;
            onBuilt();
            return result;
        }

        @java.lang.Override
        public Builder clone() {
            return super.clone();
        }

        @java.lang.Override
        public Builder setField(
            com.google.protobuf.Descriptors.FieldDescriptor field,
            java.lang.Object value) {
            return super.setField(field, value);
        }

        @java.lang.Override
        public Builder clearField(
            com.google.protobuf.Descriptors.FieldDescriptor field) {
            return super.clearField(field);
        }

        @java.lang.Override
        public Builder clearOneof(
            com.google.protobuf.Descriptors.OneofDescriptor oneof) {
            return super.clearOneof(oneof);
        }

        @java.lang.Override
        public Builder setRepeatedField(
            com.google.protobuf.Descriptors.FieldDescriptor field,
            int index, java.lang.Object value) {
            return super.setRepeatedField(field, index, value);
        }

        @java.lang.Override
        public Builder addRepeatedField(
            com.google.protobuf.Descriptors.FieldDescriptor field,
            java.lang.Object value) {
            return super.addRepeatedField(field, value);
        }

        @java.lang.Override
        public Builder mergeFrom(com.google.protobuf.Message other) {
            if (other instanceof com.aliyun.polardbx.binlog.protocol.TxnToken) {
                return mergeFrom((com.aliyun.polardbx.binlog.protocol.TxnToken) other);
            } else {
                super.mergeFrom(other);
                return this;
            }
        }

        public Builder mergeFrom(com.aliyun.polardbx.binlog.protocol.TxnToken other) {
            if (other == com.aliyun.polardbx.binlog.protocol.TxnToken.getDefaultInstance()) {
                return this;
            }
            if (!other.getTso().isEmpty()) {
                tso_ = other.tso_;
                onChanged();
            }
            if (!other.getTxnId().isEmpty()) {
                txnId_ = other.txnId_;
                onChanged();
            }
            if (!other.getPartitionId().isEmpty()) {
                partitionId_ = other.partitionId_;
                onChanged();
            }
            if (!other.getOriginMergeSourceId().isEmpty()) {
                originMergeSourceId_ = other.originMergeSourceId_;
                onChanged();
            }
            if (other.type_ != 0) {
                setTypeValue(other.getTypeValue());
            }
            if (other.getXaTxn() != false) {
                setXaTxn(other.getXaTxn());
            }
            if (other.getTsoTransaction() != false) {
                setTsoTransaction(other.getTsoTransaction());
            }
            if (other.getTxnSize() != 0) {
                setTxnSize(other.getTxnSize());
            }
            if (!other.getBeginSchema().isEmpty()) {
                beginSchema_ = other.beginSchema_;
                onChanged();
            }
            if (!other.allParties_.isEmpty()) {
                if (allParties_.isEmpty()) {
                    allParties_ = other.allParties_;
                    bitField0_ = (bitField0_ & ~0x00000001);
                } else {
                    ensureAllPartiesIsMutable();
                    allParties_.addAll(other.allParties_);
                }
                onChanged();
            }
            if (other.getPayload() != com.google.protobuf.ByteString.EMPTY) {
                setPayload(other.getPayload());
            }
            if (other.getSnapshotSeq() != 0L) {
                setSnapshotSeq(other.getSnapshotSeq());
            }
            this.mergeUnknownFields(other.unknownFields);
            onChanged();
            return this;
        }

        @java.lang.Override
        public final boolean isInitialized() {
            return true;
        }

        @java.lang.Override
        public Builder mergeFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
            com.aliyun.polardbx.binlog.protocol.TxnToken parsedMessage = null;
            try {
                parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
            } catch (com.google.protobuf.InvalidProtocolBufferException e) {
                parsedMessage = (com.aliyun.polardbx.binlog.protocol.TxnToken) e.getUnfinishedMessage();
                throw e.unwrapIOException();
            } finally {
                if (parsedMessage != null) {
                    mergeFrom(parsedMessage);
                }
            }
            return this;
        }

        private int bitField0_;

        private java.lang.Object tso_ = "";

        /**
         * <code>string tso = 1;</code>
         *
         * @return The tso.
         */
        public java.lang.String getTso() {
            java.lang.Object ref = tso_;
            if (!(ref instanceof java.lang.String)) {
                com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                tso_ = s;
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <code>string tso = 1;</code>
         *
         * @return The bytes for tso.
         */
        public com.google.protobuf.ByteString
        getTsoBytes() {
            java.lang.Object ref = tso_;
            if (ref instanceof String) {
                com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                        (java.lang.String) ref);
                tso_ = b;
                return b;
            } else {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <code>string tso = 1;</code>
         *
         * @param value The tso to set.
         * @return This builder for chaining.
         */
        public Builder setTso(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }

            tso_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>string tso = 1;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearTso() {

            tso_ = getDefaultInstance().getTso();
            onChanged();
            return this;
        }

        /**
         * <code>string tso = 1;</code>
         *
         * @param value The bytes for tso to set.
         * @return This builder for chaining.
         */
        public Builder setTsoBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            tso_ = value;
            onChanged();
            return this;
        }

        private java.lang.Object txnId_ = "";

        /**
         * <code>string txnId = 2;</code>
         *
         * @return The txnId.
         */
        public java.lang.String getTxnId() {
            java.lang.Object ref = txnId_;
            if (!(ref instanceof java.lang.String)) {
                com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                txnId_ = s;
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <code>string txnId = 2;</code>
         *
         * @return The bytes for txnId.
         */
        public com.google.protobuf.ByteString
        getTxnIdBytes() {
            java.lang.Object ref = txnId_;
            if (ref instanceof String) {
                com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                        (java.lang.String) ref);
                txnId_ = b;
                return b;
            } else {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <code>string txnId = 2;</code>
         *
         * @param value The txnId to set.
         * @return This builder for chaining.
         */
        public Builder setTxnId(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }

            txnId_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>string txnId = 2;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearTxnId() {

            txnId_ = getDefaultInstance().getTxnId();
            onChanged();
            return this;
        }

        /**
         * <code>string txnId = 2;</code>
         *
         * @param value The bytes for txnId to set.
         * @return This builder for chaining.
         */
        public Builder setTxnIdBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            txnId_ = value;
            onChanged();
            return this;
        }

        private java.lang.Object partitionId_ = "";

        /**
         * <code>string partitionId = 3;</code>
         *
         * @return The partitionId.
         */
        public java.lang.String getPartitionId() {
            java.lang.Object ref = partitionId_;
            if (!(ref instanceof java.lang.String)) {
                com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                partitionId_ = s;
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <code>string partitionId = 3;</code>
         *
         * @return The bytes for partitionId.
         */
        public com.google.protobuf.ByteString
        getPartitionIdBytes() {
            java.lang.Object ref = partitionId_;
            if (ref instanceof String) {
                com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                        (java.lang.String) ref);
                partitionId_ = b;
                return b;
            } else {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <code>string partitionId = 3;</code>
         *
         * @param value The partitionId to set.
         * @return This builder for chaining.
         */
        public Builder setPartitionId(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }

            partitionId_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>string partitionId = 3;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearPartitionId() {

            partitionId_ = getDefaultInstance().getPartitionId();
            onChanged();
            return this;
        }

        /**
         * <code>string partitionId = 3;</code>
         *
         * @param value The bytes for partitionId to set.
         * @return This builder for chaining.
         */
        public Builder setPartitionIdBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            partitionId_ = value;
            onChanged();
            return this;
        }

        private java.lang.Object originMergeSourceId_ = "";

        /**
         * <code>string originMergeSourceId = 4;</code>
         *
         * @return The originMergeSourceId.
         */
        public java.lang.String getOriginMergeSourceId() {
            java.lang.Object ref = originMergeSourceId_;
            if (!(ref instanceof java.lang.String)) {
                com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                originMergeSourceId_ = s;
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <code>string originMergeSourceId = 4;</code>
         *
         * @return The bytes for originMergeSourceId.
         */
        public com.google.protobuf.ByteString
        getOriginMergeSourceIdBytes() {
            java.lang.Object ref = originMergeSourceId_;
            if (ref instanceof String) {
                com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                        (java.lang.String) ref);
                originMergeSourceId_ = b;
                return b;
            } else {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <code>string originMergeSourceId = 4;</code>
         *
         * @param value The originMergeSourceId to set.
         * @return This builder for chaining.
         */
        public Builder setOriginMergeSourceId(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }

            originMergeSourceId_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>string originMergeSourceId = 4;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearOriginMergeSourceId() {

            originMergeSourceId_ = getDefaultInstance().getOriginMergeSourceId();
            onChanged();
            return this;
        }

        /**
         * <code>string originMergeSourceId = 4;</code>
         *
         * @param value The bytes for originMergeSourceId to set.
         * @return This builder for chaining.
         */
        public Builder setOriginMergeSourceIdBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            originMergeSourceId_ = value;
            onChanged();
            return this;
        }

        private int type_ = 0;

        /**
         * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
         *
         * @return The enum numeric value on the wire for type.
         */
        @java.lang.Override
        public int getTypeValue() {
            return type_;
        }

        /**
         * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
         *
         * @param value The enum numeric value on the wire for type to set.
         * @return This builder for chaining.
         */
        public Builder setTypeValue(int value) {

            type_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
         *
         * @return The type.
         */
        @java.lang.Override
        public com.aliyun.polardbx.binlog.protocol.TxnType getType() {
            @SuppressWarnings("deprecation")
            com.aliyun.polardbx.binlog.protocol.TxnType result =
                com.aliyun.polardbx.binlog.protocol.TxnType.valueOf(type_);
            return result == null ? com.aliyun.polardbx.binlog.protocol.TxnType.UNRECOGNIZED : result;
        }

        /**
         * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
         *
         * @param value The type to set.
         * @return This builder for chaining.
         */
        public Builder setType(com.aliyun.polardbx.binlog.protocol.TxnType value) {
            if (value == null) {
                throw new NullPointerException();
            }

            type_ = value.getNumber();
            onChanged();
            return this;
        }

        /**
         * <code>.com.aliyun.polardbx.binlog.protocol.TxnType type = 5;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearType() {

            type_ = 0;
            onChanged();
            return this;
        }

        private boolean xaTxn_;

        /**
         * <code>bool xaTxn = 6;</code>
         *
         * @return The xaTxn.
         */
        @java.lang.Override
        public boolean getXaTxn() {
            return xaTxn_;
        }

        /**
         * <code>bool xaTxn = 6;</code>
         *
         * @param value The xaTxn to set.
         * @return This builder for chaining.
         */
        public Builder setXaTxn(boolean value) {

            xaTxn_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>bool xaTxn = 6;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearXaTxn() {

            xaTxn_ = false;
            onChanged();
            return this;
        }

        private boolean tsoTransaction_;

        /**
         * <pre>
         * *
         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段，
         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
         * </pre>
         *
         * <code>bool tsoTransaction = 7;</code>
         *
         * @return The tsoTransaction.
         */
        @java.lang.Override
        public boolean getTsoTransaction() {
            return tsoTransaction_;
        }

        /**
         * <pre>
         * *
         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段，
         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
         * </pre>
         *
         * <code>bool tsoTransaction = 7;</code>
         *
         * @param value The tsoTransaction to set.
         * @return This builder for chaining.
         */
        public Builder setTsoTransaction(boolean value) {

            tsoTransaction_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * 标识是否为Tso事务。虽然【Tso事务】和【NoTso事务】的Token都有tso字段，
         * 但是【NoTso事务】的tso是根据其前序【Tso事务】的真实tso生成的虚拟tso
         * </pre>
         *
         * <code>bool tsoTransaction = 7;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearTsoTransaction() {

            tsoTransaction_ = false;
            onChanged();
            return this;
        }

        private int txnSize_;

        /**
         * <pre>
         * *
         * 该事务下的所有LogEvent的个数，注意：不是某个批次的的个数
         * </pre>
         *
         * <code>int32 txnSize = 8;</code>
         *
         * @return The txnSize.
         */
        @java.lang.Override
        public int getTxnSize() {
            return txnSize_;
        }

        /**
         * <pre>
         * *
         * 该事务下的所有LogEvent的个数，注意：不是某个批次的的个数
         * </pre>
         *
         * <code>int32 txnSize = 8;</code>
         *
         * @param value The txnSize to set.
         * @return This builder for chaining.
         */
        public Builder setTxnSize(int value) {

            txnSize_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * 该事务下的所有LogEvent的个数，注意：不是某个批次的的个数
         * </pre>
         *
         * <code>int32 txnSize = 8;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearTxnSize() {

            txnSize_ = 0;
            onChanged();
            return this;
        }

        private java.lang.Object beginSchema_ = "";

        /**
         * <pre>
         * *
         * dumper生成事务的begin头时使用
         * </pre>
         *
         * <code>string beginSchema = 9;</code>
         *
         * @return The beginSchema.
         */
        public java.lang.String getBeginSchema() {
            java.lang.Object ref = beginSchema_;
            if (!(ref instanceof java.lang.String)) {
                com.google.protobuf.ByteString bs =
                    (com.google.protobuf.ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                beginSchema_ = s;
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <pre>
         * *
         * dumper生成事务的begin头时使用
         * </pre>
         *
         * <code>string beginSchema = 9;</code>
         *
         * @return The bytes for beginSchema.
         */
        public com.google.protobuf.ByteString
        getBeginSchemaBytes() {
            java.lang.Object ref = beginSchema_;
            if (ref instanceof String) {
                com.google.protobuf.ByteString b =
                    com.google.protobuf.ByteString.copyFromUtf8(
                        (java.lang.String) ref);
                beginSchema_ = b;
                return b;
            } else {
                return (com.google.protobuf.ByteString) ref;
            }
        }

        /**
         * <pre>
         * *
         * dumper生成事务的begin头时使用
         * </pre>
         *
         * <code>string beginSchema = 9;</code>
         *
         * @param value The beginSchema to set.
         * @return This builder for chaining.
         */
        public Builder setBeginSchema(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }

            beginSchema_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * dumper生成事务的begin头时使用
         * </pre>
         *
         * <code>string beginSchema = 9;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearBeginSchema() {

            beginSchema_ = getDefaultInstance().getBeginSchema();
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * dumper生成事务的begin头时使用
         * </pre>
         *
         * <code>string beginSchema = 9;</code>
         *
         * @param value The bytes for beginSchema to set.
         * @return This builder for chaining.
         */
        public Builder setBeginSchemaBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);

            beginSchema_ = value;
            onChanged();
            return this;
        }

        private com.google.protobuf.LazyStringList allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY;

        private void ensureAllPartiesIsMutable() {
            if (!((bitField0_ & 0x00000001) != 0)) {
                allParties_ = new com.google.protobuf.LazyStringArrayList(allParties_);
                bitField0_ |= 0x00000001;
            }
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @return A list containing the allParties.
         */
        public com.google.protobuf.ProtocolStringList
        getAllPartiesList() {
            return allParties_.getUnmodifiableView();
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @return The count of allParties.
         */
        public int getAllPartiesCount() {
            return allParties_.size();
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param index The index of the element to return.
         * @return The allParties at the given index.
         */
        public java.lang.String getAllParties(int index) {
            return allParties_.get(index);
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param index The index of the value to return.
         * @return The bytes of the allParties at the given index.
         */
        public com.google.protobuf.ByteString
        getAllPartiesBytes(int index) {
            return allParties_.getByteString(index);
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param index The index to set the value at.
         * @param value The allParties to set.
         * @return This builder for chaining.
         */
        public Builder setAllParties(
            int index, java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }
            ensureAllPartiesIsMutable();
            allParties_.set(index, value);
            onChanged();
            return this;
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param value The allParties to add.
         * @return This builder for chaining.
         */
        public Builder addAllParties(
            java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }
            ensureAllPartiesIsMutable();
            allParties_.add(value);
            onChanged();
            return this;
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param values The allParties to add.
         * @return This builder for chaining.
         */
        public Builder addAllAllParties(
            java.lang.Iterable<java.lang.String> values) {
            ensureAllPartiesIsMutable();
            com.google.protobuf.AbstractMessageLite.Builder.addAll(
                values, allParties_);
            onChanged();
            return this;
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearAllParties() {
            allParties_ = com.google.protobuf.LazyStringArrayList.EMPTY;
            bitField0_ = (bitField0_ & ~0x00000001);
            onChanged();
            return this;
        }

        /**
         * <code>repeated string allParties = 10;</code>
         *
         * @param value The bytes of the allParties to add.
         * @return This builder for chaining.
         */
        public Builder addAllPartiesBytes(
            com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            checkByteStringIsUtf8(value);
            ensureAllPartiesIsMutable();
            allParties_.add(value);
            onChanged();
            return this;
        }

        private com.google.protobuf.ByteString payload_ = com.google.protobuf.ByteString.EMPTY;

        /**
         * <pre>
         * *
         * 一些特殊的TxnToken，没有TxnItem的概念，此时通过payload字段传输数据
         * </pre>
         *
         * <code>bytes payload = 11;</code>
         *
         * @return The payload.
         */
        @java.lang.Override
        public com.google.protobuf.ByteString getPayload() {
            return payload_;
        }

        /**
         * <pre>
         * *
         * 一些特殊的TxnToken，没有TxnItem的概念，此时通过payload字段传输数据
         * </pre>
         *
         * <code>bytes payload = 11;</code>
         *
         * @param value The payload to set.
         * @return This builder for chaining.
         */
        public Builder setPayload(com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }

            payload_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * 一些特殊的TxnToken，没有TxnItem的概念，此时通过payload字段传输数据
         * </pre>
         *
         * <code>bytes payload = 11;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearPayload() {

            payload_ = getDefaultInstance().getPayload();
            onChanged();
            return this;
        }

        private long snapshotSeq_;

        /**
         * <pre>
         * *
         * Tso事务专用
         * </pre>
         *
         * <code>int64 snapshotSeq = 12;</code>
         *
         * @return The snapshotSeq.
         */
        @java.lang.Override
        public long getSnapshotSeq() {
            return snapshotSeq_;
        }

        /**
         * <pre>
         * *
         * Tso事务专用
         * </pre>
         *
         * <code>int64 snapshotSeq = 12;</code>
         *
         * @param value The snapshotSeq to set.
         * @return This builder for chaining.
         */
        public Builder setSnapshotSeq(long value) {

            snapshotSeq_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * *
         * Tso事务专用
         * </pre>
         *
         * <code>int64 snapshotSeq = 12;</code>
         *
         * @return This builder for chaining.
         */
        public Builder clearSnapshotSeq() {

            snapshotSeq_ = 0L;
            onChanged();
            return this;
        }

        @java.lang.Override
        public final Builder setUnknownFields(
            final com.google.protobuf.UnknownFieldSet unknownFields) {
            return super.setUnknownFields(unknownFields);
        }

        @java.lang.Override
        public final Builder mergeUnknownFields(
            final com.google.protobuf.UnknownFieldSet unknownFields) {
            return super.mergeUnknownFields(unknownFields);
        }

        // @@protoc_insertion_point(builder_scope:com.aliyun.polardbx.binlog.protocol.TxnToken)
    }

    // @@protoc_insertion_point(class_scope:com.aliyun.polardbx.binlog.protocol.TxnToken)
    private static final com.aliyun.polardbx.binlog.protocol.TxnToken DEFAULT_INSTANCE;

    static {
        DEFAULT_INSTANCE = new com.aliyun.polardbx.binlog.protocol.TxnToken();
    }

    public static com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstance() {
        return DEFAULT_INSTANCE;
    }

    private static final com.google.protobuf.Parser<TxnToken>
        PARSER = new com.google.protobuf.AbstractParser<TxnToken>() {
        @java.lang.Override
        public TxnToken parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
            return new TxnToken(input, extensionRegistry);
        }
    };

    public static com.google.protobuf.Parser<TxnToken> parser() {
        return PARSER;
    }

    @java.lang.Override
    public com.google.protobuf.Parser<TxnToken> getParserForType() {
        return PARSER;
    }

    @java.lang.Override
    public com.aliyun.polardbx.binlog.protocol.TxnToken getDefaultInstanceForType() {
        return DEFAULT_INSTANCE;
    }

}

